<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>计算属性的getter 与setter</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="app">
    {{fullName}}
  </div>
  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        firstName: "xiao",
        lastName: "ming"
      },
      computed: {
        fullName: {
          // getter
          get: function () {
            return this.firstName + " " + this.lastName;
          },
          // setter
          set: function(val) {
            var arr = val.split(' ');
            this.firstName = arr[0];
            this.lastName = arr[1];
            console.log(val);
          }
        }
      }
    })
    
    
    
  </script>
</body>
</html>